package com.goldcn.order.controller;

import com.goldcn.goods.model.GoodsClassifyRebate;
import com.goldcn.goods.service.GoodsService;
import com.goldcn.interceptor.SystemContext;
import com.goldcn.order.service.RebateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by Administrator on 2017/9/6.
 */
@Api(value = "分销价格&佣金系数设置")
@RestController
@RequestMapping(value = "/rebate")
public class RebateController {
    @Autowired
    RebateService rebateService;
    @Autowired
    GoodsService goodsService;

    @ApiOperation(value = "添加或者修改分类对应的扣点值")
    @RequestMapping(value = "/rate", method = RequestMethod.POST)
    public Object saveClassifyVal(@RequestBody Map<String, String> map) {
        return rebateService.saveRebateVal_v2(map);
    }

    //云管控获取本系统的分类查询2级并出品类
    @ApiOperation(value = "一级分类列表")
    @RequestMapping(value = "/clazz/{sellerID}", method = RequestMethod.GET)
    public Object getClassifyListById(@PathVariable Long sellerID) {
        return rebateService.getClassListLevel(sellerID);
    }

    @ApiOperation(value = "二级分类列表")
    @RequestMapping(value = "/subClazz/{clazzId}/{sellerID}", method = RequestMethod.GET)
    public Object getSubClassListLevel(@PathVariable String clazzId, @PathVariable Long sellerID) {
        return rebateService.getSubClassListLevel(sellerID, clazzId);
    }

    @ApiOperation(value = "添加修改中收规则")
    @RequestMapping(value = "/rule", method = RequestMethod.POST)
    public Object saveRule(@RequestBody Map<String, String> map) {
        return rebateService.saveRule(map);
    }

    @ApiOperation(value = "查询中收规则")
    @RequestMapping(value = "/rule", method = RequestMethod.GET)
    public Object getRule() {
        return rebateService.selectByCompanyID(SystemContext.getCompanyID());
    }


    @ApiOperation(value = "查询店铺员工佣金设置")
    @RequestMapping(value = "/shop/{shopID}", method = RequestMethod.GET)
    public Object getShopByShopId(@PathVariable Long shopID) {
        return rebateService.selectListByShopID(RebateService.SHOP_COMMISSION_RATE, shopID);

        // return rebateService.selectListBySellID(shopID);
    }

    @ApiOperation(value = "设置店铺员工佣金设置")
    @RequestMapping(value = "/shop", method = RequestMethod.POST)
    public Object saveShopConfig(@RequestBody GoodsClassifyRebate shopRebate) {
        return rebateService.saveShopData(shopRebate);


    }
}
